#include <iostream>
#include <google/gflags.h>
#include "gflags_sample.h"

static bool ValidateHttp_port(const char* flagname, int32_t value)
{
  if (value > 0 && value < 32678)
  {
    return true;
  }
  fprintf(stderr, "Invalid value for --%s: %d\n", flagname, (int)value);
  return false;
}

DEFINE_bool(memory_pool, false, "if use memory pool");
DEFINE_string(module_id, "gflag_sample1", "service module id");
DEFINE_int32(http_port, 80, "http listen port");
DEFINE_int32(https_port, 443, "https listen port");
DEFINE_int64(online_number, 10, "online number of qq");
DEFINE_uint64(online_number1, 20, "online number 001 of qq");
DEFINE_double(tax, 0.05, "my tax");

static const bool http_port_dummy = ::google::RegisterFlagValidator(&FLAGS_http_port, &ValidateHttp_port);

int main(int argc, char** argv)
{
  ::google::ParseCommandLineFlags(&argc, &argv, true);

	fprintf(stderr, "module id[%s]\n", FLAGS_module_id.c_str());

	if (FLAGS_memory_pool)
	{
		fprintf(stderr, "use memory pool[%d]\n", FLAGS_memory_pool);
	}
  else
  {
    fprintf(stderr, "use memory pool[%d]\n", FLAGS_memory_pool);
  }

  fprintf(stderr, "http_port[%d] https_port[%d] online_number[%ld] "
                  "online_number1[%lu] tax[%f]\n", 
      FLAGS_http_port, 
      FLAGS_https_port,
      FLAGS_online_number,
      FLAGS_online_number1,
      FLAGS_tax);

  Server oServer;

	return 0;
}

